package com.wnxy.service.impl;

import com.wnxy.bean.User;
import com.wnxy.mapper.UserMapper;
import com.wnxy.service.UserService;
import com.wnxy.util.DBUtil;
import org.apache.ibatis.session.SqlSession;

public class UserServiceImpl implements UserService {
    @Override
    public boolean addUser(User user) {

         SqlSession sqlSession= DBUtil.openSession(true);

         UserMapper  mapper=sqlSession.getMapper(UserMapper.class);

         Integer result=mapper.insert(user);

         sqlSession.close();

         return  result!=0;
    }


    public User loginUser(String userName,String userPwd){

        SqlSession  sqlSession=DBUtil.openSession(true);

        UserMapper mapper=sqlSession.getMapper(UserMapper.class);

        User user=mapper.selectByNameAndPwd(userName,userPwd);

        sqlSession.close();

        return user;

    }



}
